// 对所有的用户相关操作进行封装
import axios from '@/utils/request'

// 用户登录接口
export const login = (mobile, code) => {
  return axios({
    method: 'POST',
    url: '/app/v1_0/authorizations',
    data: {
      mobile: mobile,
      code: code
    }
  })
}

// 获取用户信息
export const getProfile = (mobile, code) => {
  return axios({
    method: 'GET',
    url: '/app/v1_0/user/profile'
  })
}

// 关注用户
export const followUser = (userId) => {
  return axios({
    url: '/app/v1_0/user/followings',
    method: 'POST',
    data: {
      target: userId
    }
  })
}

// 取消关注用户
export const unFollowUser = userId => {
  return axios({
    url: '/app/v1_0/user/followings/' + userId,
    method: 'DELETE'
  })
}

// 获取用户自己的信息
export const getInfo = () => {
  return axios({
    method: 'GET',
    url: '/app/v1_0/user'
  })
}

// 获取用户的个人信息
export const getUserInfo = () => {
  return axios({
    method: 'GET',
    url: '/app/v1_0/user/profile'
  })
}

// 修改个人信息
export const updateUserInfo = obj => {
  return axios({
    method: 'PATCH',
    url: '/app/v1_0/user/profile',
    data: obj
  })
}

// 修改用户头像
export const updatePhoto = obj => {
  return axios({
    method: 'PATCH',
    url: '/app/v1_0/user/photo',
    data: obj
    // data: {
    //   photo: xxxx
    // }
  })
}
